
import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
import CommonView from './MiddleCommonView';
var Home_D4 = require('../../LocalData/XMG_Home_D4');
export default class MiddleBottomView extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.topViewStyle}>

        </View>
        <View style={styles.bottomViewStyle}>
          {this._renderBottomItem()}
        </View>
      </View>
    );
  }
  _renderBottomItem(){
    var itemArr = [];
    var dataArr = Home_D4.data;
    for(var i=0; i<dataArr.length; i++){
      var itemData = dataArr[i];
      itemArr.push(
        <CommonView 
        key={i} 
        title={itemData.maintitle} 
        subTitle={itemData.deputytitle} 
        rightImage={this.dealWithImgUrl(itemData.imageurl)} 
        titleColor={itemData.typeface_color}
        tplurl={itemData.tplurl}
        />);
    }
    return itemArr;
  }
  dealWithImgUrl(url){
    if(url.search('w.h') == -1){
      return url;
    } else {
      return url.replace('w.h','120.90');
    }
  }
}

const styles = StyleSheet.create({
  container: {
    marginTop:15,
  },
  topViewStyle:{

  },
  bottomViewStyle:{
    flexDirection:'row',
    flexWrap:'wrap',
  }
});
